﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Sub.TaskPlanningDesk.Model.Objects;
using System.ComponentModel.DataAnnotations;

namespace Sub.TaskPlanningDesk.WebSite.ViewModels.Tasks
{
	public class TaskModel
	{
		public Project Project { private set; get; }

		[Required]
		[Display(Name = "Task overview:")]
		public string Overview { get; set; }

		[Display(Name = "Task Description:")]
		public string Description { get; set; }

		public int? ID { get; set; }

		public bool IsNew { private set; get; }

		public Task GetTask()
		{
			return new Task()
			{
				Overview = Overview,
				Description = Description,
				ProjectID = Project.ID
			};
		}

		public TaskModel(Project project, Task task, bool isNew)
		{
			Project = project;
			IsNew = isNew;
			
			if(!isNew)
				ID = task.ID;

			Overview = task.Overview;
			Description = task.Description;
		}
	}
}